<template>
  <div>
    <h3>About --- {{ num }}</h3>
    <button @click="add">++</button>
    <!-- <button @click="push(1)">张三登录</button>
    <button @click="push(2)">李四登录</button> -->
  </div>
</template>

<script>
import { useRoute, useRouter } from 'vue-router'
import { useCount } from '../hooks/count'
import { my } from '../router/config'
export default {
  setup() {
    // useRoute()  当前路由信息
    const route = useRoute
    // useRouter()  路由实例
    const router = useRouter()

    // console.log(router)

    const push = (auth) => {
      // addRoute 动态添加路由
      if (auth === 2) {
        router.addRoute(my)
        router.push('/my')
      } else {
        router.replace('/')
      }
    }

    const { num, add } = useCount()
    return {
      push,
      num,
      add
    }
  }
}
</script>

<style>

</style>